<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
        <button @click="fn">按钮</button>
        <p ref="ref">{{msg}}</p>
    </div>
    <script src="./node_modules/vue/dist/vue.js"></script>
    <script>
       //   dom更新是异步
        //    我们把代码放在nextTick当中,在下一次dom更新的时候执行
        // data更新 --> dom更新 (nextTick) --> data更新 --> dom更新 



    //   event loop ---> ui渲染   
      var vm = new Vue({
        el: '#app',
        data: {
            msg:'hello world'
        },
        methods: {
            fn(){
                this.msg = 'hello vue'
                this.$nextTick(()=>{
                    console.log(this.$refs.ref.innerHTML)
                })
            }
        },
      })
    </script>
  </body>
</html>
